#include <iostream>
#include <vector>
#include <map>

using std::cout;
using std::endl;
using std::vector;
using std::map;

// int fourSumCount(vector<int>& A, vector<int>& B, vector<int>& C, vector<int>& D)
int fourSumCount(const vector<int>& A, const vector<int>& B, const vector<int>& C, const vector<int>& D)
{
    map<int,int> mab;
    int count = 0;
    for(int i = 0;i < A.size();++ i)
    {
        for(int j = 0;j < B.size();++ j)
        {
            int add = A[i] + B[j];
            int n = mab.count(add);
            n == 0 ? mab[add] = 1 : ++ mab[add];
        }
    }

    for(int i = 0;i < C.size();++ i)
    {
        for(int j = 0;j < D.size();++ j)
        {
            int add = C[i] + C[j];
            count += mab.count((0 - add));
        }
    }

    return count;
}

int main(int argc, char const *argv[])
{
    int n = fourSumCount({1,2},{-2,-1},{-1,2},{0,2}); 
    cout << "n:" << n << endl;
    getchar();
    return 0;
}
